#include "amscene.h"

AMScene * AMScene::get() {
    static AMScene * theInstance = new AMScene();
    return theInstance;
}

AMScene::AMScene() {
    m_LightCount = 0;
}

void AMScene::renderEnity() {
    QLinkedListIterator<AMLight> lightsIter (m_Lights);
    while(lightsIter.hasNext()) {
        lightsIter.next().render();
    }

    QLinkedListIterator<AMVirtualEntity *> entityIter (m_Entities);
    while(entityIter.hasNext()) {
        entityIter.next()->render();
    }
}

bool AMScene::add(AMVirtualEntity * entity) {
    m_Entities.append(entity);
    return true;
}

bool AMScene::add(const AMLight & light) {
    if(m_LightCount > 8) {
        return false;
    }
    m_Lights.append(light);
    ++m_LightCount;
    return true;
}

void AMScene::clear() {
    m_Entities.clear();
    m_Lights.clear();
}

void AMScene::clearEntities() {
    m_Entities.clear();
}
